﻿@{
    ViewData["Title"] = "Index";
    Layout = "~/Views/Shared/_Index_Layout.cshtml";
    ViewFWUser currentUserInfo = base.Context.Session.GetUserInfo();
}
@if (currentUserInfo.IsHaveRights("Demo_StudentEdit", "00"))
{
@section styles{
}
@section scripts{
    @*<script src="~/js/views/Main/Home/index.js" asp-append-version="true"></script>*@
}

<table id="myDg"></table>
<div id="myDg-toolbar" data-options="grid:{
            type:'edatagrid',
            id:'myDg'
        }" class="topjui-toolbar">

    @if (currentUserInfo.IsHaveRights("Demo_StudentEdit", "01"))
    {
        <a href="javascript:void(0)"
            data-toggle="topjui-menubutton"
            data-options="method:'edatagrid',
            extend: '#myDg-toolbar',
            iconCls:'fa fa-plus',
            btnCls:'topjui-btn-export',
            type:'addRow'">@L("新增")</a>
    }

    <a href="javascript:void(0)"
        data-toggle="topjui-menubutton"
        data-options="method:'edatagrid',
        extend: '#myDg-toolbar',
        iconCls:'fa fa-save',
        btnCls:'topjui-btn-brown',
        type:'saveRow'">@L("保存")</a>

    <a href="javascript:void(0)"
        data-toggle="topjui-menubutton"
        data-options="method:'edatagrid',
        extend: '#myDg-toolbar',
        iconCls:'fa fa-remove',
        btnCls:'topjui-btn-black',
        type:'cancelRow'">@L("取消")</a>

    @if (currentUserInfo.IsHaveRights("Demo_StudentEdit", "02"))
    {
        <a href="javascript:void(0)"
               data-toggle="topjui-menubutton"
               data-options="method:'edatagrid',
               extend: '#myDg-toolbar' ,
               iconCls:'fa fa-remove',
               btnCls:'topjui-btn-blue',
               type:'destroyRow'">@L("删除")</a>
    }
   
    <a href="javascript:void(0)"
        data-toggle="topjui-menubutton"
        data-options="method:'filter',
        extend: '#myDg-toolbar',
        btnCls:'topjui-btn-filter'">@L("过滤")</a>

    <a href="javascript:void(0)"
           data-toggle="topjui-menubutton"
           data-options="
           method:'search',
           extend: '#myDg-toolbar',
           btnCls:'topjui-btn-query'">@L("查询")</a>
</div>

<script>

    var dg = $('#myDg').iEdatagrid({
        idField: 'id',
        url: '/api/services/app/DemoStudentEdit/GetGridDto',
        reloadAfterSave: false,
        saveUrl: '/api/services/app/DemoStudentEdit/CreateByDto',
        updateUrl: '/api/services/app/DemoStudentEdit/UpdateByDto',
        destroyUrl: '/api/services/app/DemoStudentEdit/DeleteByDto',
        queryParams: {
            order: 'CreateTime  desc',
            viewName: 'view_Demo_StudentEdit'
        },
        columns: [
            [
                {
                    field: 'id',
                    title: 'id',
                    checkbox: true,
                },

                {
                    field: 'classGUID',
                    title: '@L("班级GUID")',
                    width: 120,
                    sortable: true,
                    editor: {
                        type: 'combobox',
                        options: {
                            editable: true,
                            valueField: 'id',
                            textField: 'text',
                            loader: $.loader.comboxLoader,
                            mode: 'remote',
                            queryParams:
                            {
                                viewName: 'View_Demo_class',
                                comBoxValueName: 'className'
                            }
                        }
                    }
                },

                {
                    field: 'studentName',
                    title: '@L("名称")',
                    width: 120,
                    sortable: true,
                    editor: { type: 'textbox', options: { required: false, height: 30 } }
                },

                {
                    field: 'studentAge',
                    title: '@L("年龄")',
                    width: 120,
                    sortable: true,
                    editor: { type: 'numberbox', options: { required: false, height: 30 } }
                },

                {
                    field: 'studentBirthday',
                    title: '@L("生日")',
                    width: 120,
                    sortable: true,
                    formatter: $.ei.dateFormatter,
                    editor: { type: 'datebox', options: { required: false, height: 30 } }
                },

                {
                    field: 'studentHeight',
                    title: '@L("身高")',
                    width: 120,
                    sortable: true,
                    formatter: $.ei.moneyFormatter,
                    editor: { type: 'numberbox', options: { required: false, height: 30, precision: 2 } }
                },

                {
                    field: 'studentIsVip',
                    title: '@L("是否VIP")',
                    width: 120,
                    sortable: true,
                    formatter: $.ei.boolFormatter,
                    editor: { type: 'combobox', options: { required: false, height: 30, data: [{ value: '', text: '' }, { value: '1', text: '@L("是")' }, { value: '0', text: '@L("否")' }] } }
                },

                {
                    field: 'studentLevel',
                    title: '@L("学生等级(1,学霸;2,普通;3,学渣)")',
                    width: 120,
                    sortable: true,
                    formatter: $.ei.colEnumFormatter('@L("学生等级(1,学霸;2,普通;3,学渣)")'),
                    editor: {
                        type: 'combobox', options: {
                            required: false,
                            height: 30,
                            valueField: 'value',
                            url: '/api/services/app/Enum/GetEnumArray',
                            queryParams: {
                                'enumTypeName': 'DemoStudentEditStudentLevelEnum', 'module': 'Demo'
                            }
                        }
                    }
                },

                {
                    field: 'studentDesc',
                    title: '@L("学生描述")',
                    width: 120,
                    sortable: true,
                    editor: { type: 'textbox', options: { required: false, height: 30 } }
                },

{
                    field: 'studentFavor',
                    title: '@L("学生爱好(篮球;足球;羽毛球;跑步)")',
                    width: 120,
                    sortable: true,
                    editor: {
                        type: 'combobox', options:
                        {
                            required: false,
                            height: 30,
                            multiple: true,
                            data: [
                                { value: '篮球', text: '篮球' },
                                { value: '足球', text: '足球' },
                                { value: '羽毛球', text: '羽毛球' },
                                { value: '跑步', text: '跑步' },
                            ]
                        }
                    }
                },

                {
                    field: 'studentStudentHeadUrl',
                    title: '@L("学生头像(上传图片)")',
                    width: 120,
                    sortable: true,
                    editor: { type: 'textbox', options: { required: false, height: 30 } }
                },

                {
                    field: 'studentMeRemark',
                    title: '@L("学生自传")',
                    width: 120,
                    sortable: true,
                    editor: { type: 'textbox', options: { required: false, height: 30 } }
                },

            ]
        ],
        frozenColumns: [[

        ]],
        filter: [
            {
                field: 'studentName',
                type: 'textbox',
                op: ['contains', 'equal', 'notequal', 'endwith', 'beginwith']
            },

            {
                field: 'studentAge',
                type: 'numberbox',
                op: ['equal', 'notequal', 'less', 'lessorequal', 'greater', 'greaterorequal']
            },

            {
                field: 'studentBirthday',
                type: 'datebox',
                op: ['equal', 'notequal', 'less', 'lessorequal', 'greater', 'greaterorequal'],
                dataType: 'datetime'
            },

            {
                field: 'studentHeight',
                type: 'numberbox',
                op: ['equal', 'notequal', 'less', 'lessorequal', 'greater', 'greaterorequal'],
                options: {
                    precision: 2
                }
            },

            {
                field: 'studentIsVip',
                type: 'combobox',
                options: {
                    valueField: 'value',
                    textField: 'text',
                    editable: false,
                    data: [{
                        text: '是',
                        value: '1'
                    }, {
                        text: '否',
                        value: '0'
                    }]
                },
                op: ['equal', 'notequal',]
            },

            {
                field: 'studentLevel',
                editable: false,
                type: 'combobox',
                op: ['equal', 'notequal'],
                dataType: 'int',
                options: {
                    valueField: 'value',
                    textField: 'text',
                    url: '/api/services/app/Enum/GetEnumArray',
                    queryParams: {
                        'enumTypeName': 'DemoStudentEditStudentLevelEnum', 'module': 'Demo'
                    }
                }
            },

            {
                field: 'studentDesc',
                type: 'textbox',
                op: ['contains', 'equal', 'notequal', 'endwith', 'beginwith']
            },

            {
                field: 'studentFavor',
                type: 'textbox',
                op: ['contains', 'equal', 'notequal', 'endwith', 'beginwith']
            },

            {
                field: 'studentStudentHeadUrl',
                type: 'textbox',
                op: ['contains', 'equal', 'notequal', 'endwith', 'beginwith']
            },

            {
                field: 'studentMeRemark',
                type: 'textbox',
                op: ['contains', 'equal', 'notequal', 'endwith', 'beginwith']
            },


        ],
        onDblClickRow: function () {

        }
    });
</script>
}
else
{
    <h1>@L("你没有该页面的权限")</h1>
}

